﻿using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using CID.Domain.Infrastructure;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace CID.Web.Models.Infrastructure
{
    public class ParameterViewModel : BaseDescribedViewModel<IParameter>
    {
        #region Properties
        [Required(ErrorMessage = "You must provide a Type")]
        [JsonConverter(typeof(StringEnumConverter))]
        public ParameterType Type { get; set; }

        [HiddenInput(DisplayValue = false)]
        public bool _destroy { get; set; }
        #endregion

        public ParameterViewModel() : base() { }

        public ParameterViewModel(IParameter model) : base(model)
        {
            Type = model.Type;
        }

        public override void UpdateModel(IParameter model)
        {
            base.UpdateModel(model);
            model.Type = Type;
        }
    }
}